/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
  <file> uls_const.h </file>
  <brief>
    A common file for all the ULS sources.
    This file is part of ULS, Unified Lexical Scheme.
  </brief>
  <author>
    Stanley J. Hong <babel96@gmail.com>, August 2011.
  </author>
*/

#ifndef __ULS_CONST_H__
#define __ULS_CONST_H__

#include "uls_config.h"

#define ULS_MB_CUR_MAX    8
#define ERR_TOK_IDX       0
#define EOI_TOK_IDX       1
#define EOF_TOK_IDX       2
#define ID_TOK_IDX        3
#define NUM_TOK_IDX       4
#define LINENUM_TOK_IDX   5
#define NONE_TOK_IDX      6
#define N_RESEVED_TOKS    7
#define UTF8_CH_MAXLEN    4

#define ULS_STREAM_RAW    0
#define ULS_STREAM_BIN_LE 1
#define ULS_STREAM_BIN_BE 2

#define ULC_COLUMNS_MAXSIZ       16
#define ULS_STREAM_SUBNAME_SIZE  31
#define ULS_STREAM_CTIME_SIZE    20

#define ULS_CNST_SUFFIX_MAXSIZ   3
#define ULS_CNST_SUFFIXES_MAXSIZ 31

#define ULS_FL_VERBOSE    0x20000000
#define ULS_FL_SILENT     0x10000000

#define ULS_HASH_ALGORITHM "ULF-HASH"

/* The lexer will ignore the chars having this flag. */

// '-', '.', 0 1 2 3 4 5 6 7 8 9
#define ULS_CH_DIGIT   0x01

/* one-uls_char_t token candidate */
#define ULS_CH_1       0x02

/* the tokens consiting of multi-chars. */
#define ULS_CH_2PLUS   0x04

/* The uls_char_t-number will be used for literal-string token. */
#define ULS_CH_QUOTE   0x08

/* The uls_char_t having this flag may be the first uls_char_t of ID */
#define ULS_CH_IDFIRST 0x10

/* The uls_char_t having this flag may be a uls_char_t of ID */
#define ULS_CH_ID      0x20

/* The tok-id of uls_char_t having this flag is NOT the ASCII-code. */
#define ULS_CH_TOKID_REMAPPED   0x40

/* The uls_char_t-number was reserverd as token-id. */
#define ULS_CH_COMM    0x80

#define uls_ch_isspace(ch_ctx, ch)     (ch_ctx[ch]==0)
#define uls_ch_isidfirst(ch_ctx, ch)   (ch_ctx[ch] & ULS_CH_IDFIRST)
#define uls_ch_isid(ch_ctx, ch)        (ch_ctx[ch] & ULS_CH_ID)
#define uls_ch_isquote(ch_ctx, ch)     (ch_ctx[ch] & ULS_CH_QUOTE)
#define uls_ch_istoken_1ch(ch_ctx, ch) (ch_ctx[ch] & ULS_CH_1)
#define uls_ch_istoken_2ch(ch_ctx, ch) (ch_ctx[ch] & ULS_CH_2PLUS)
#define uls_ch_iscomm(ch_ctx, ch)      (ch_ctx[ch] & ULS_CH_COMM)
#define uls_ch_isdigit(ch_ctx, ch)     (ch_ctx[ch] & ULS_CH_DIGIT)

#endif
